package com.telchina.rcbg.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.telchina.common.core.controller.BaseController;
import com.telchina.common.core.domain.AjaxResult;
import com.telchina.common.core.domain.entity.SysOrg;
import com.telchina.common.utils.SecurityUtils;
import com.telchina.rcbg.domain.ProclamationInfo;
import com.telchina.rcbg.service.IProclamationInfoService;
import com.telchina.workorder.third.service.SystemThirdService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * @Auther: zlm
 * @Date: 2023/3/27
 * @Description: com.telchina.rcbg.controller
 * @Version: 1.0
 */
@RestController
@RequestMapping("rcbg/proclamationInfo")
public class ProclamationInfoController extends BaseController {

    @Resource
    private IProclamationInfoService proclamationInfoService;

    /**
     * 保存
     *
     * @param info info
     * @return
     */
    @PostMapping("/save")
    public AjaxResult save(@RequestBody ProclamationInfo info) {
        proclamationInfoService.saveWithLoginUser(info);
        return AjaxResult.success(info);
    }

    /**
     * 修改
     *
     * @param info info
     * @return
     */
    @PostMapping("/modify")
    public AjaxResult modify(@RequestBody ProclamationInfo info) {
        proclamationInfoService.modifyById(info);
        return AjaxResult.success(info);
    }

    /**
     * 删除
     *
     * @param id 主键
     * @return
     */
    @GetMapping("/delete/{id}")
    public AjaxResult delete(@PathVariable("id") String id) {
        proclamationInfoService.removeByIdWithAttachment(id);
        return AjaxResult.success();
    }

    /**
     * 详情
     *
     * @param id 主键
     * @return
     */
    @GetMapping("/getByIdWithAttachment/{id}")
    public AjaxResult get(@PathVariable("id") String id) {
        ProclamationInfo info = proclamationInfoService.getByIdWithAttachment(id);
        return AjaxResult.success(info);
    }

    /**
     * 分页查询
     *
     * @param pageNum    页码
     * @param pageSize   每页条数
     * @param queryParam 查询条件
     * @return
     */
    @GetMapping("/pageList")
    public AjaxResult pageList(@RequestParam(required = false, defaultValue = "1") Integer pageNum, @RequestParam(required = false, defaultValue = "10") Integer pageSize, ProclamationInfo queryParam) {
        IPage<ProclamationInfo> page = proclamationInfoService.pageList(pageNum, pageSize, queryParam);
        return AjaxResult.success(page);
    }
}
